/*
 *Copyright (c) 2024 Black Sesame Technologies
 *
 *Licensed under the Apache License, Version 2.0 (the "License");
 *you may not use this file except in compliance with the License.
 *You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 *Unless required by applicable law or agreed to in writing, software
 *distributed under the License is distributed on an "AS IS" BASIS,
 *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *See the License for the specific language governing permissions and
 *limitations under the License.
*/
#ifndef CAN_HSCG_IPW_H
#define CAN_HSCG_IPW_H

#ifdef __cplusplus
extern "C"{
#endif



/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
#include "Can_HSCG.h"

/*==================================================================================================
*                                          CONSTANTS
==================================================================================================*/

/*==================================================================================================
*                                      DEFINES AND MACROS
==================================================================================================*/
#define         CAN_LPDU_ID_MASK_U32                                                        ((uint32)0x3FFFFFFFU)
#define         CAN_LPDU_IDE_U32                                                            ((uint32)0x80000000U)
#define         CAN_LPDU_FD_U32                                                             ((uint32)0x40000000) 
#define         HSCG_NULL_OFFSET_U8                                                         ((uint8)0xFFU)

#define         CAN_FD_FRAME_LEN                                                            64U
#define         CAN_STD_FRAME_LEN                                                           8U
#define         MAX_BUFFER_FRAME_FD                                                         64


#define         CAN_HSCG_NULL_OFFSET                                                     (HSCG_NULL_OFFSET_U8)
#define         Can_HSCG_IPW_InitPlatform()                                              (Can_Hscg_InitPlatform())
#define         Can_HSCG_IPW_InitController()                                            (Can_Hscg_InitController())
#define         Can_HSCG_IPW_SetMBRuleFilters(Controller)                                (Can_Hscg_SetMBRuleFilters(Controller))
#define         Can_HSCG_IPW_SetEnhancedFifoFilters(Controller)                          (Can_Hscg_SetEnhancedFifoFilters(Controller))
#define         Can_HSCG_IPW_DeInitController(Controller)                                (Can_Hscg_DeInitController(Controller))
#define         Can_HSCG_IPW_DeInitPlatform()                                            (Can_Hscg_DeInitPlatform())
#define         Can_HSCG_IPW_ChangeBaudrate(Controller)                                  (Can_Hscg_ChangeBaudrate(Controller))
#define         Can_HSCG_IPW_GetControllerMode(Controller, ControllerModePtr)            (Can_Hscg_GetControllerMode((Controller), (ControllerModePtr)))
#define         Can_HSCG_IPW_SetControllerMode(Controller, Transition)                   (Can_Hscg_SetControllerMode((Controller), (Transition)))
#define         Can_HSCG_IPW_DisableControllerInterrupts(Controller)                     (Can_Hscg_DisableControllerInterrupts((Controller)))
#define         Can_HSCG_IPW_EnableControllerInterrupts(Controller)                      (Can_Hscg_EnableControllerInterrupts((Controller)))
#define         Can_HSCG_IPW_Write(Hth, PduInfo)                                         (Can_Hscg_Write((Hth), (PduInfo)))
#define         Can_HSCG_IPW_Start()                                                     (Can_Hscg_Start())
#define         Can_HSCG_IPW_Stop()                                                      (Can_Hscg_Stop())
   



#if (CAN_HSCG_TXPOLL_SUPPORTED == STD_ON)
    #if (CAN_HSCG_MAINFUNCTION_MULTIPLE_WRITE == STD_OFF)
        /** @violates @ref CAN_IPW_h_REF_1 Violates MISRA 2012 Advisory Rule 4.9,  Function like macro are used to reduce code complexity */
        #define         Can_HSCG_IPW_MainFunctionWrite()                                               (Can_Hscg_MainFunctionWrite())
    #else
        /** @violates @ref CAN_IPW_h_REF_1 Violates MISRA 2012 Advisory Rule 4.9,  Function like macro are used to reduce code complexity */
        #define         Can_HSCG_IPW_MainFunctionMultipleWritePoll(writepoll)                          (Can_Hscg_MainFunctionMultipleWritePoll(writepoll))
    #endif
#endif
    
#if (CAN_HSCG_RXPOLL_SUPPORTED == STD_ON)
    #if (CAN_HSCG_MAINFUNCTION_MULTIPLE_READ == STD_OFF)
        /** @violates @ref CAN_IPW_h_REF_1 Violates MISRA 2012 Advisory Rule 4.9,  Function like macro are used to reduce code complexity */
        #define         Can_HSCG_IPW_MainFunctionRead()                                                (Can_Hscg_MainFunctionRead())
    #else
        /** @violates @ref CAN_IPW_h_REF_1 Violates MISRA 2012 Advisory Rule 4.9,  Function like macro are used to reduce code complexity */
        #define         Can_HSCG_IPW_MainFunctionMultipleReadPoll(readpoll)                            (Can_Hscg_MainFunctionMultipleReadPoll(readpoll))
    #endif 
#endif  

#if (CAN_HSCG_ERRORNOTIFPOLL_SUPPORTED == STD_ON)
    /** @violates @ref CAN_IPW_h_REF_1 Violates MISRA 2012 Advisory Rule 4.9,  Function like macro are used to reduce code complexity */
    #define         Can_HSCG_IPW_ProcessErrorNotification(void)                               (Can_Hscg_ProcessErrorNotification(void))
#endif    


#define         Can_HSCG_IPW_MainFunctionMode()                                          (Can_Hscg_MainFunctionMode())
#define         Can_HSCG_IPW_GetControllerErrorState(Controller,ErrorStatePtr)           (Can_Hscg_GetControllerErrorState(Controller,ErrorStatePtr))
#define         Can_HSCG_IPW_GetControllerRxErrorCounter(ControllerId,RxErrorCounterPtr) (Can_Hscg_GetControllerRxErrorCounter(ControllerId,RxErrorCounterPtr))
#define         Can_HSCG_IPW_GetControllerTxErrorCounter(ControllerId,TxErrorCounterPtr) (Can_Hscg_GetControllerTxErrorCounter(ControllerId,TxErrorCounterPtr))
#define         Can_HSCG_IPW_GetFwVersion(pVersionString, u8StringLength)                (Can_Hscg_GetFwVersion(pVersionString, u8StringLength))                           
#define         Can_HSCG_IPW_GetControllerStatus(Controller, StatusPtr)                  (Can_Hscg_GetControllerStatus(Controller, StatusPtr))                            

/*==================================================================================================
*                                             ENUMS
==================================================================================================*/

/*==================================================================================================
*                                STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/

/*==================================================================================================
*                                GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/

/*==================================================================================================
*                                    FUNCTION PROTOTYPES
==================================================================================================*/
#ifdef __cplusplus
}
#endif

#endif /* CAN_HSCG_IPW_H */

/** @} */
